



					**This file runs ITS specifications for noncap data**	

			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**


use removalcounts, clear





**
*Make indicator variables
**


gen centeredmonth = month-policymonth

replace centeredmonth = 0 if policymonth == .

*Indicator variables for each centered month variable (only 5 years before and after)
tab centeredmonth if centeredmonth >= -10 & centeredmonth <= 10, gen(indcentered)

* Rename these 
forv j = 1/10{
	loc k = abs(`j' - 11)
	rename indcentered`j' indcenteredN`k'
}
forv j = 11/21{
	loc k = `j' - 11
	rename indcentered`j' indcentered`k'
}

*Now set first indicator to include all previous obs and last to include all subsequent
replace indcenteredN10 = 1 if centeredmonth <= -10
replace indcentered10 = 1 if centeredmonth >= 10 

* Change order of indcenteredN0 (for which y - y* = 0) so that is omitted category
order indcentered0, last

*Replace missing months with zeros 
foreach var of varlist ind* {
replace `var' = 0 if `var' != 1
}

gen noncap = countymonthlytotal - capcount

glm noncap i.month i.statecounty ind*, family(nbinomial ml) ///
cluster(state) link(log) irls


preserve

* Get coef
regsave indcenteredN10-indcentered10, detail(all)

* Create variables
gen ub = coef + 1.96   * stderr  * sqrt(deviance/df)
gen lb = coef - 1.96 * stderr  * sqrt(deviance/df)

* Generate time variable and other graphing stuff
gen time = _n-11
replace time = time+1 if time > -1

twoway (rspike ub lb time , lw(0.3) lc(gray)) (scatter coef time , msize(small) msymbol(circle) ), ///
	yli(0, lpattern(dash) lc(black)) ///
	ylab(-1.4(.2)0.6, labsize(small) angle(horizontal)) xlab(-10(2)10, labsize(small)) ///
	title("Non-Local-Arrest Deportations") ///
	ytitle("Change in Log Deportations" "Relative to Date of Policy") xtitle("Months Since Sanctuary Policy") ///
	graphregion( fcolor(white) lcolor(white)) plotregion(fcolor(white) lstyle(none) lcolor(white) ilstyle(none)) ///
	legend(off) xsize(5) ysize(3) 
graph export "fig4.pdf", replace

restore

